﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MySql.Data.MySqlClient;

namespace ZEFIT
{
    class MYSQLAdapterWorkingCategory : Adabter
    {
        public override List<object> Select()
        {
            String conString = "SELECT ID, Name FROM tbl_aufgabe;";
            List<object> reader = MYSQLConnecter.SelectRows(new MySqlCommand(conString));
            return reader;
        }

        public override void Insert(ref Data data)
        {
            WorkingCategory category = (WorkingCategory)data;

            String conString = "INSERT INTO tbl_aufgabe (Name) VALUES" +
                " ('" + category.Name + "');";
            category.Id = MYSQLConnecter.SendInsert(new MySqlCommand(conString));

        }

        public override void Update(Data data)
        {
            WorkingCategory category = (WorkingCategory)data;

            String conString = "UPDATE tbl_aufgabe" +
                " SET Name = '" + category.Name + "'" +
                " WHERE ID = " + category.Id + ";";
            MYSQLConnecter.Send(new MySqlCommand(conString));
        }

        public override void Delete(int id)
        {
            String conString = "DELETE FROM tbl_aufgabe" +
                " WHERE ID = " + id + ";";
            MYSQLConnecter.Send(new MySqlCommand(conString));
        }
    }
}
